﻿<%@ Page Title="注册" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="RegexLib.Web.Views.Member.Register" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="box">
	<div class="bt">新用户注册</div>
	<div class="bc">
	<form id="RegForm" action="/Member/RegisterSubmit" method="post">
		<p>请输入您的Email地址：<input type="text" class="input" name="userEmail" maxlength="256" /></p>
	</form>
	<div><button id="SubmitBtn">提交申请</button></div>
	<p><span id="MsgSpan"></span></p>
	</div>
</div>
</asp:Content>

<asp:Content ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<script type="text/javascript">
var c_RegForm;
var c_SubmitBtn;
var c_MsgSpan;

function GetElements()
{
	c_RegForm = YAHOO.util.Dom.get("RegForm");
	c_SubmitBtn = YAHOO.util.Dom.get("SubmitBtn");
	c_MsgSpan = YAHOO.util.Dom.get("MsgSpan");
}

function RegFail(o)
{
	c_MsgSpan.className = "err";
	c_MsgSpan.innerText = "连接错误。";
	c_SubmitBtn.disabled = false;
}

function RegSuccess(o)
{
	try
	{
		var data = YAHOO.lang.JSON.parse(o.responseText);
		if(data.IsError)
			c_MsgSpan.className = "err";
		else
		{
			c_MsgSpan.className = "suc";
			c_RegForm.reset();
		}
			
		c_MsgSpan.innerText = data.Message;
	}
	catch(e)
	{
		c_MsgSpan.className = "err";
		c_MsgSpan.innerText = "解析响应时出错。";
	}
	c_SubmitBtn.disabled = false;
}

function DoRegister()
{
	c_SubmitBtn.disabled = true;
	
	var callback =
	{
		success: RegSuccess,
		failure: RegFail,
		timeout: 30000
	};
	
	YAHOO.util.Connect.setForm(c_RegForm);
	YAHOO.util.Connect.asyncRequest("POST", "/Member/RegisterSubmit/", callback, null);
}

function init()
{
	GetElements();
	YAHOO.util.Event.addListener(c_SubmitBtn, "click", DoRegister);
}

YAHOO.util.Event.onDOMReady(init);
</script>
</asp:Content>